package com.example.bootdemo.redis.controller;

import com.example.bootdemo.redis.aop.AccessLimiter;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class HelloController {
    /**
     * 设置用户禁止平凡的请求接口，只能在一秒钟请求3次
     * @return
     */
    @GetMapping("/hello")
    @AccessLimiter(timeout = 1, limit = 3) // 1秒钟超过3次限流
    public String index() {
        // 分布锁
        return "success";
    }

    @GetMapping("/hello2")
    public String index2() {
        return "success";
    }
}
